<template>
	<view class="">
		<view class="shows">
			<view class="" v-for="(doctor,index) in doctorlist" :key="index">
				<view class="imglist" @click="setdoctor(doctor.DoctorId)">
					<view class="imgleft">
						<u--image :src="doctor.Img" width="90" height="100"></u--image>
					</view>
					<view class="imgcount">
						<span class="name">{{doctor.DoctorName}}</span>
						<span class="tab">{{doctor.CompName}} {{doctor.DptName}}</span>
						<span class="describe">{{doctor.Description}}</span>
					</view>
				</view>
				<u-divider></u-divider>
			</view>
			<span @click="getlist"><u-loadmore :status="status" /></span>
			<view class="botu">
				
			</view>
		</view>
				
	</view>
</template>

<script>
	import {
		mapState,
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {
				status: 'loadmore',
				page: 1,
				rows: 5,
				doctorlist: []
			}
		},
		created() {
			
		},
		computed: {
			...mapState(['token'], ['userInfo']),
			...mapGetters(['hasLogin', 'getUserInfo'])
		},
		onShow() {
			if (this.hasLogin) {
				uni.showLoading({
					title: '加载中'
				})
				this.$store.dispatch('getUserInfo');
				this.getdoctor()
			} else {
				uni.hideLoading();
				uni.showModal({
					title: '提示',
					content: '登录后才可以操作',
					confirmText: '去登录',
					showCancel: false,
					success: function(res) {
						uni.reLaunch({
							url: '/pages/auth/login'
						})
					}
				});
				return;
			}
		
		},
		methods: {
			getlist(){
				this.status="loading"
				this.getdoctor()
			},
			setdoctor(DoctorId){
				//let doctors=JSON.stringify(doctor)
				uni.navigateTo({
					url: `/pages/doctor/collectlist/collectlist?DoctorId=${DoctorId}`,
					fail(error) {
						console.log(error)
					}
				})
			},
			getdoctor() {
				this.$request('Collection', 'Mycollection').then(res => {
					let doctor = res.data
					if (doctor.length > 0) {
						this.doctorlist = doctor
						this.status="loadmore"
					}
					if(doctor.length%5>0){
						this.status="nomore"
					}
					uni.hideLoading();
					console.log(this.doctorlist)
				})
			}
		}

	}
</script>

<style>
	@import './collect.css'
</style>


<style lang="scss" scoped>
	.wrap {
		padding: 24rpx;
	}
	
	.item {
		padding: 24rpx 0;
		color: $u-content-color;
		font-size: 28rpx;
	}
</style>